import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { FGTeamInfo } from "./FGTeamInfo";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { StringHelper } from "../../../../com/gengine/utils/StringHelper";
import { GButton } from "../../../../com/mui/controls/GButton";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SFootballGameInfo } from "../../../../Message/Game/SFootballGameInfo";
type int = number;
//class FGAlertWindow
    
    export  class FGAlertWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(340, 170);
            this.titleHeight = 28;
            this.title = Language.getString(54129);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(17, 39, 305, 123, this);
            this._tip1Txt = ObjCreate.createTextField("", 24, 50, 300, 20, this);
            this._tip1Txt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._tip1Txt.multiline = true;
            this._tip1Txt.wordWrap = true;
            this._okBtn = ObjCreate.createGButton(Language.getString(52012), 80, 120, 70, 24, this);
            this._okBtn.name = "ok";
            this._cancelBtn = ObjCreate.createGButton(Language.getString(52013), 180, 120, 70, 24, this);
            this._okBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            this._cancelBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            return;
        }

        public updateByGameInfo(arg1: FGTeamInfo, arg2: Boolean, arg3: Function=null): void
        {
            var loc1=null;
            var loc2=null;
            this._teamInfo = arg1;
            this._gameInfo = arg1.gameInfo;
            this._clickFun = arg3;
            if (this._gameInfo) 
            {
                if (arg2) 
                {
                    this._team = this._gameInfo.teamA;
                    this._teamName = this._gameInfo.teamAName;
                }
                else 
                {
                    this._team = this._gameInfo.teamB;
                    this._teamName = this._gameInfo.teamBName;
                }
                loc1 = HTMLUtil.addColor(this._teamName, GlobalStyle.color2, "", 20);
                loc2 = HTMLUtil.addColor(Language.getString(51143), "", "", 20);
                this._tip1Txt.htmlText = StringHelper.substitute(loc2, loc1);
            }
            return;
        }

        /* internal  */onBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc2=0;
            var loc3=0;
            var loc4=0;
            var loc1=(arg1.target as GButton).name;
            if (loc1 != "ok") 
            {
                this._isOk = false;
                this.hide();
            }
            else 
            {
                this._isOk = true;
                if (this._gameInfo) 
                {
                    loc2 = this._gameInfo.type;
                    loc3 = this._gameInfo.group;
                    loc4 = this._team;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.FootballGuessTeam, {"type": loc2, "group": loc3, "team": loc4, "callBack": this.hide}));
                }
            }
            if (this._clickFun != null) 
            {
                this._clickFun(this._isOk);
            }
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            if (!this._isOk && !(this._clickFun == null)) 
            {
                this._clickFun(false);
            }
            return;
        }

        /* internal */ /* var */_tip1Txt: Object /* flash.text.TextField */;

        /* internal */ /* var */_tip2Txt: Object /* flash.text.TextField */;

        /* internal */ /* var */_okBtn: GButton;

        /* internal */ /* var */_cancelBtn: GButton;

        /* internal */ /* var */_teamInfo: FGTeamInfo;

        /* internal */ /* var */_gameInfo: SFootballGameInfo;

        /* internal */ /* var */_team: int;

        /* internal */ /* var */_teamName: string;

        /* internal */ /* var */_clickFun: Function;

        /* internal */ /* var */_isOk: Boolean;
    }
